package cn.easybuy.service.news;

import java.sql.Connection;
import java.util.ArrayList;
import java.util.List;

import cn.easybuy.dao.news.NewsDao;
import cn.easybuy.dao.news.NewsDaoImpl;
import cn.easybuy.entity.News;
import cn.easybuy.utils.DataSourceUtil;

public class NewsServiceImpl implements NewsService {
	
	private Connection conn;
	private NewsDao newsDao;

	@Override
	public List<News> queryAllnews() throws Exception {
		
		List<News> newsList = new ArrayList<News>();
		
		conn = DataSourceUtil.openConnection();
		
		newsDao = new NewsDaoImpl(conn);
		//调用方法
		newsList = newsDao.queryAllnews();
		//关闭数据库连接
		DataSourceUtil.closeConnection(conn);
		return newsList;
	}

}